﻿@model PerformanceAssessment.Models.AssessmentPeriod

@{
    ViewBag.Title = "Details";
}

@section Head
{
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        $(document).ready(function () {
            $("#return-message").dialog({
                modal: true,
                autoOpen: false,
                buttons: {
                    Ok: function () {
                        $(this).dialog("close");
                    }
                }
            });

            $("#dialog-message").dialog({
                modal: true,
                autoOpen: false,
                buttons: {
                    Ok: function () {
                        $.ajax({
                            type: "POST",
                            url: '@Url.Action("SendNotification")',
                            datatype: "json",
                            data: { periodId: '@Model.ID' },
                            success: function (data) {
                                $("#errorMessage").text(data.error);
                                $("#return-message").dialog("open");
                            }
                        });
                        $(this).dialog("close");
                    },
                    Cancel: function () {
                        $(this).dialog("close");
                    }
                }
            });
        });

        function SendNotification() {
            $("#dialog-message").dialog("open");
        }
    </script>
}

<div id="dialog-message" title="Send confirmation">
	<p>
		<span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 50px 0;"></span>
		<span>Are you sure you want to send a notification to all the users that belong to the Teams for this Period?</span>
	</p>
</div>

<div id="return-message" title="Submit Error">
	<p>
		<span class="ui-icon ui-icon-info" style="float:left; margin:0 7px 50px 0;"></span>
		<span id="errorMessage" ></span>
	</p>
</div>


<h2>Details</h2>

<fieldset>
    <legend>Assessment Period</legend>

    <div class="display-label">Description</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Description)
    </div>

    <div class="display-label">Start Date</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.FromDate)
    </div>

    <div class="display-label">End Date</div>
    <div class="display-field">
        @Html.DisplayFor(model => model.ToDate)
    </div>

    <div class="display-label">Previous Assessment Period</div>
    <div class="display-field">
        @if (Model.PreviousAssessmentPeriod != null)
        {
            @Html.Label(Model.PreviousAssessmentPeriod.Description)
        }
    </div>
    <div class="editor-label">
        Evaluated Teams
    </div>
    <ul id="Teams">
        @for (int i = 0; i < Model.Teams.Count; i++)
        {
            <li>
                <label>@Model.Teams[i].Name</label>
            </li>
        }
    </ul>
</fieldset>

<input type="button" value="Send Notification" onclick="SendNotification()" />
<p>
    @Html.ActionLink("Edit", "Edit", new { id=Model.ID }) |
    @Html.ActionLink("Back to List", "Index")
</p>
